package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Address;
import com.itheima.service.AddressService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地址管理控制器(前台)
 */
@RestController
@RequestMapping("/address")
public class AddressController {

    //从zookeeper中引入地址管理服务
    @Reference
    private AddressService addressService;

    /**
     * 查询所有地址名称
     * @return
     */
    @RequestMapping("/findLocation")
    public Result findPage(){
        try {
            List<String> locations = addressService.findLocation();
            return new Result(true,MessageConstant.QUERY_LOCATION_SUCCESS,locations);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_LOCATION_FAIL);
        }
    }


}
